import sitemap from './config/sitemap.js'
const pluginsValue = [
  '@/plugins/i18n',
  {
    src: '@/plugins/element-ui',
    ssr: false,
  },
  {
    src: '@/api/axios/index',
    ssr: false,
  },
  {
    src: '@/api/plugin',
    ssr: true,
  },
  {
    src: '@/plugins/vue-lazyload',
    ssr: false
  },
  {
    src: '@/plugins/vue-cropper',
    ssr: false
  },
  {
    src: '@/plugins/vue-particles',
    ssr: false
  },
]
console.log('process.env.NODE_ENV ', process.env.NODE_ENV)
// 下载，导出数据会发生问题
if (process.env.NODE_ENV === 'development') {
  // https://blog.csdn.net/qq_21567385/article/details/108251232
  // pluginsValue.push({
  //   src: '@/plugins/mock/index.js',
  //   ssr: true,
  // })
}
console.log('pluginsValue====>', pluginsValue)
const config = {
  // Global page headers: https://go.nuxtjs.dev/config-head
  env: {
    // NUXT_ENV_MODE: env[process.env.MODE],
  },
  extensions: ['.tsx', '.ts', '.mjs', '.js', '.jsx', '.vue', '.json', '.wasm'],
  loading: { color: '#3B8070' },
  head: {
    title: 'nuxt-demo',
    htmlAttrs: {
      lang: 'cn',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      {
        rel: 'stylesheet',
        href: `//at.alicdn.com/t/font_3314296_5h9yctg8uyn.css`,
      },
    ],
    script: [
      { src: `//at.alicdn.com/t/font_3314296_5h9yctg8uyn.js`, defer: true }, // 加载icon脚本
      { src: `./js/three.js`, defer: true }, // 加载icon脚本
      { src: `./js/3d-force-graph.js`, defer: true }, // 加载icon脚本
    ],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: ['~/assets/css/_root.css'],
  styleResources: {
    scss: ['~/assets/css/variable.scss']
  },

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: pluginsValue || [],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxtjs/sitemap',
    '@nuxtjs/style-resources'
  ],
  sitemap,

  server: {
    port: process.env.NUXT_ENV_MODE === 'dev' ? 9000 : 80,
    host: '127.0.0.1',
  },

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {
    // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
    proxy: true,
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    analyze: process.env.NODE_ENV === 'production',
    transpile: [/^element-ui/],
    vendor: ['vue-i18n', 'axios'],
    babel: {
      plugins: [
        [
          'component',
          {
            libraryName: 'element-ui',
            styleLibraryName: 'theme-chalk',
          },
        ],
      ],
    },
    optimization: {
      splitChunks: {
        minSize: 10000,
        maxSize: 250000,
      },
    },
  },
}
export default config
